home *** CD-ROM | disk | FTP | other *** search
- Path: news.dseg.ti.com!news
- From: grubin@ti.com (Geoffrey Rubin)
- Newsgroups: comp.lang.c++
- Subject: Re: Scope/longevity of class statics
- Date: 16 Feb 1996 20:55:17 GMT
- Organization: AWP
- Message-ID: <4g2qvl$3pr@mksrv1.dseg.ti.com>
- References: <4fu0qc$1h0@news.dcccd.edu> <4fvr6l$m1l@news.halcyon.com>
- NNTP-Posting-Host: cna0185662.dseg.ti.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=ISO-8859-1
- X-Newsreader: WinVN 0.99.5
-
- In article <4fvr6l$m1l@news.halcyon.com>, normanb@halcyon.com says...
- >
- >bcalbridge@dcccd.edu (Bob Calbridge) wrote:
- >
- >>I know this sounds odd but since things didn't seem to work as
- >>expected I'll put the question to the newsgroup. I have some
- >>class static data that represents an upper left corner offset
- >>for all display data. In order to set the value I applied it
- >>to a temporary class object inside a function. It seemed to
- >>work find for my purposes. However, when I moved the code that
- >>set the values to another function that was invoked prior to the
- >>original function where it was instigated the values ended up
- >>improperly set by the time I got to my main code.
- >
- Class static data still "belongs" to the class. If a temporary object
- is created of some class type inside the first function, it should not be
- accessed after that function has exited. When the function exits, the
- temporary goes out of scope and its destructor is called, and therefore
- its static data should not be considered valid.
-
- Geoffrey
-
-